package com.ruoyi.project.jiaqin.quotationcollect.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.jiaqin.quotationcollect.domain.QuotationCollect;
import com.ruoyi.project.jiaqin.quotationcollect.service.IQuotationCollectService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 行情收藏Controller
 * 
 * @author LCL
 * @date 2021-10-23
 */
@Controller
@RequestMapping("/jiaqin/quotationcollect")
public class QuotationCollectController extends BaseController
{
    private String prefix = "jiaqin/quotationcollect";

    @Autowired
    private IQuotationCollectService quotationCollectService;

    @RequiresPermissions("jiaqin:quotationcollect:view")
    @GetMapping()
    public String quotationcollect()
    {
        return prefix + "/quotationcollect";
    }

    /**
     * 查询行情收藏列表
     */
    @RequiresPermissions("jiaqin:quotationcollect:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(QuotationCollect quotationCollect)
    {
        startPage();
        List<QuotationCollect> list = quotationCollectService.selectQuotationCollectList(quotationCollect);
        return getDataTable(list);
    }

    /**
     * 导出行情收藏列表
     */
    @RequiresPermissions("jiaqin:quotationcollect:export")
    @Log(title = "行情收藏", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(QuotationCollect quotationCollect)
    {
        List<QuotationCollect> list = quotationCollectService.selectQuotationCollectList(quotationCollect);
        ExcelUtil<QuotationCollect> util = new ExcelUtil<QuotationCollect>(QuotationCollect.class);
        return util.exportExcel(list, "quotationcollect");
    }

    /**
     * 新增行情收藏
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存行情收藏
     */
    @RequiresPermissions("jiaqin:quotationcollect:add")
    @Log(title = "行情收藏", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(QuotationCollect quotationCollect)
    {
        return toAjax(quotationCollectService.insertQuotationCollect(quotationCollect));
    }

    /**
     * 修改行情收藏
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        QuotationCollect quotationCollect = quotationCollectService.selectQuotationCollectById(id);
        mmap.put("quotationCollect", quotationCollect);
        return prefix + "/edit";
    }

    /**
     * 修改保存行情收藏
     */
    @RequiresPermissions("jiaqin:quotationcollect:edit")
    @Log(title = "行情收藏", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(QuotationCollect quotationCollect)
    {
        return toAjax(quotationCollectService.updateQuotationCollect(quotationCollect));
    }

    /**
     * 删除行情收藏
     */
    @RequiresPermissions("jiaqin:quotationcollect:remove")
    @Log(title = "行情收藏", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(quotationCollectService.deleteQuotationCollectByIds(ids));
    }
}
